using UnityEngine;
// [Assembly-CSharp.dll].GameController
public class GameController : MonoBehaviour
{
    
    #region GameController.STATE
    // [Assembly-CSharp.dll].GameController.STATE
    public enum STATE
    {
        // Fields
        DRAWING = 0
        ,PLAYING = 1
        ,FINISH = 2
        ,GAMEOVER = 3
        
    
    }
    
    #endregion
    
    // Fields
    public Level currentLevel;
    public int levelIndex;
    public int maxLevel;
    public static GameController instance;
    public bool activeDog;
    public UnityEngine.GameObject drawManager;
    public UIManager uiManager;
    private Spider spider;
    public GameController.STATE currentState;
    public int[] maxInk;
    
    // Methods
    private void Awake()
    {
        mem2[0] = this;
        this.currentState = 0;
        if((UnityEngine.PlayerPrefs.GetInt(key:  -1610605633)) == 1)
        {
                this.levelIndex = UnityEngine.PlayerPrefs.GetInt(key:  -1610605635);
            this.LoveMode();
            return;
        }
        
        if((UnityEngine.PlayerPrefs.GetInt(key:  -1610608821)) == 1)
        {
                this.levelIndex = UnityEngine.PlayerPrefs.GetInt(key:  -1610608823);
            this.ChallangeMode();
            return;
        }
        
        this.levelIndex = UnityEngine.PlayerPrefs.GetInt(key:  -1610608379);
        this.CreateLevel();
    }
    private void Start()
    {
        this.spider = UnityEngine.Object.FindObjectOfType<System.Object>();
    }
    private void Update()
    {
        if((UnityEngine.Input.GetMouseButtonUp(button:  0)) == false)
        {
                return;
        }
        
        if(this.currentState != 0)
        {
                return;
        }
        
        if(this.activeDog == false)
        {
                return;
        }
        
        this.ActiveDog();
        if(this.spider == 0)
        {
                return;
        }
        
        this.spider.move = true;
    }
    public void ActiveDog()
    {
        var val_12;
        this.currentState = 1;
        this.uiManager.ActiveClock();
        var val_12 = 0;
        label_9:
        if(val_12 >= W9)
        {
            goto label_4;
        }
        
        this.currentLevel.dogList.Item[0].transform.GetChild(index:  UnityEngine.PlayerPrefs.GetInt(key:  -1610599417)).GetComponent<System.Object>().bodyType = 0;
        val_12 = val_12 + 1;
        if(this.currentLevel != null)
        {
            goto label_9;
        }
        
        label_4:
        var val_13 = 0;
        label_19:
        if(val_13 >= W9)
        {
            goto label_12;
        }
        
        this.currentLevel.stoneList.Item[0].GetComponent<System.Object>().bodyType = 0;
        this.currentLevel.stoneList.Item[0].GetComponent<System.Object>().mass = 3f;
        val_13 = val_13 + 1;
        if(this.currentLevel != null)
        {
            goto label_19;
        }
        
        label_12:
        var val_14 = 0;
        label_25:
        if(val_14 >= W9)
        {
            goto label_22;
        }
        
        this.currentLevel.restrictedAreas.Item[0].gameObject.SetActive(value:  false);
        val_14 = val_14 + 1;
        if(this.currentLevel != null)
        {
            goto label_25;
        }
        
        label_22:
        val_12 = 0;
        label_31:
        if(val_12 >= this.currentLevel.guide.Length)
        {
                return;
        }
        
        if(val_12 >= this.currentLevel.guide.Length)
        {
            goto label_29;
        }
        
        this.currentLevel.guide[val_12].SetActive(value:  false);
        val_12 = val_12 + 1;
        if(this.currentLevel != null)
        {
            goto label_31;
        }
        
        throw new NullReferenceException();
        label_29:
    }
    private void CreateLevel()
    {
        int val_8;
        string val_9;
        if(((UnityEngine.PlayerPrefs.HasKey(key:  -1610609139)) != true) && (this.levelIndex >= 2))
        {
                UnityEngine.PlayerPrefs.SetInt(key:  -1610609139, value:  1);
            mem2[0] = 1;
            UnityEngine.Debug.Log(message:  -1610606981);
        }
        
        val_8 = this.levelIndex;
        int val_8 = this.maxLevel;
        val_8 = val_8 - val_8;
        if(this.levelIndex >= 2)
        {
                val_8 = val_8;
            this.levelIndex = val_8;
        }
        
        val_8 = val_8 + 1;
        this.currentLevel = UnityEngine.Object.Instantiate(original:  UnityEngine.Resources.Load(path:  -1610605723(-1610605723) + val_8.ToString())).GetComponent<System.Object>();
        if(this.currentLevel != null)
        {
                val_9 = this.currentLevel;
        }
        else
        {
                val_9 = 0;
        }
        
        Firebase.Analytics.FirebaseAnalytics.LogEvent(name:  -1610608387(-1610608387) + val_9);
    }
    private void LoveMode()
    {
        int val_8;
        string val_9;
        if(((UnityEngine.PlayerPrefs.HasKey(key:  -1610609139)) != true) && (this.levelIndex >= 2))
        {
                UnityEngine.PlayerPrefs.SetInt(key:  -1610609139, value:  1);
            mem2[0] = 1;
            UnityEngine.Debug.Log(message:  -1610606981);
        }
        
        val_8 = this.levelIndex;
        int val_8 = this.maxLevel;
        val_8 = val_8 - val_8;
        if(this.levelIndex >= 2)
        {
                val_8 = val_8;
            this.levelIndex = val_8;
        }
        
        val_8 = val_8 + 1;
        this.currentLevel = UnityEngine.Object.Instantiate(original:  UnityEngine.Resources.Load(path:  -1610605631(-1610605631) + val_8.ToString())).GetComponent<System.Object>();
        if(this.currentLevel != null)
        {
                val_9 = this.currentLevel;
        }
        else
        {
                val_9 = 0;
        }
        
        Firebase.Analytics.FirebaseAnalytics.LogEvent(name:  -1610608383(-1610608383) + val_9);
    }
    private void ChallangeMode()
    {
        string val_8;
        if(((UnityEngine.PlayerPrefs.HasKey(key:  -1610609139)) != true) && (this.levelIndex >= 2))
        {
                UnityEngine.PlayerPrefs.SetInt(key:  -1610609139, value:  1);
            mem2[0] = 1;
            UnityEngine.Debug.Log(message:  -1610606981);
        }
        
        int val_8 = this.levelIndex;
        val_8 = val_8 + 1;
        this.currentLevel = UnityEngine.Object.Instantiate(original:  UnityEngine.Resources.Load(path:  -1610608825(-1610608825) + val_8.ToString())).GetComponent<System.Object>();
        if(this.currentLevel != null)
        {
                val_8 = this.currentLevel;
        }
        else
        {
                val_8 = 0;
        }
        
        Firebase.Analytics.FirebaseAnalytics.LogEvent(name:  -1610608385(-1610608385) + val_8);
    }
    public GameController()
    {
    
    }

}
